import os

from selenium import webdriver
from selenium.webdriver.common.by import By

from Page.PageObject.LoginPage import LoginPage
import time

if __name__ == "__main__":
    # 测试代码

    options = webdriver.ChromeOptions()
    options.add_experimental_option("excludeSwitches", ['enable-automation', 'load-extension'])  # 屏蔽自动化受控提示 && 开发者提示
    options.add_argument("--start-maximized")  # 浏览器启动时窗口最大化

    # 禁用“保存密码”弹出窗口
    options.add_experimental_option("prefs", {"credentials_enable_service": False,
                                              "profile.password_manager_enabled": False})

    driver = webdriver.Chrome(options=options)
    driver.implicitly_wait(5)

    # driver = webdriver.Firefox()
    login = LoginPage(driver, 10)
    login.login('11', '123456')
    # login.assert_login_button_exist('11')
    time.sleep(1)
    print(f'start click Language button')
    driver.find_element(By.CLASS_NAME, 'icon-lang').click()

    time.sleep(1)
    print(f'start click English button')
    driver.find_element(By.XPATH, '//li[text()="English"]').click()

    time.sleep(1)
    print(f'start click Alarm button')

    driver.find_element(By.CSS_SELECTOR, '.iconfont.icon-weihu').click()
    time.sleep(1)
    driver.find_element(By.CSS_SELECTOR, '.iconfont.icon-jiankong').click()
    time.sleep(1)
    driver.find_element(By.CSS_SELECTOR, '.iconfont.icon-a-2').click()
    time.sleep(1)
    driver.find_element(By.CSS_SELECTOR, '.iconfont.icon-archive-drawer-fill').click()
    time.sleep(1)
    driver.find_element(By.CSS_SELECTOR, '.iconfont.icon-shouye').click()
    time.sleep(1)

    # driver.find_element(By.XPATH, '//div[@class="navbar"]/div/i[text()="Alarm"]/..').click()
    # driver.find_element(By.XPATH, '//div[@class="navbar"]/div/i[text()=" Alarm "]/..').click()
    # driver.find_elements(By.XPATH, '//div[@class="navbar"]')
    time.sleep(1111)
